package com.example.demo.dto;

import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
public class UserResponseDto {
    private Integer id;
    private String account;
    private String username;
    private String avatar; // 新增 avatar 字段
    private LocalDateTime addTime;
    private LocalDateTime updateTime;
    private Integer bookCount;

    // 从 User 实体转换的构造函数或静态工厂方法
    public static UserResponseDto fromUser(com.example.demo.entity.User user) {
        UserResponseDto dto = new UserResponseDto();
        dto.setId(user.getId());
        dto.setAccount(user.getAccount());
        dto.setUsername(user.getUsername());
        dto.setAvatar(user.getAvatar()); // 设置 avatar 字段
        dto.setAddTime(user.getAddTime());
        dto.setUpdateTime(user.getUpdateTime());
        dto.setBookCount(user.getBookCount());
        return dto;
    }
}
